****************************************
****************************************
****                                ****
****          Manuscript            ****
****       Generating DV & IVs      ****
****                                ****
****************************************
****************************************
****************************************


/// Makes sure Israel is omitted from analysis -- data collection issues [not part of sample] ///
gen sample = 1 if ccode!=666

****************************************
****************************************
//// 1. GENERATE STATE RESPONSE VARIABLE 
****************************************
****************************************
gen state_response = .
replace state_response = 1 if disregard==1
replace state_response = 2 if police==1
replace state_response = 3 if accommodate==1
replace state_response = 4 if coercion==1
tab state_response

*****************************************
*****************************************
//// 2. GENERATE DISRUPTION COST VARIABLE
*****************************************
*****************************************

// size //
gen protest_size = . if sample==1
replace protest_size = 0 if PartNumbers_low<100 & sample==1
replace protest_size = 1 if PartNumbers_low>99&PartNumbers_low<1000 & sample==1
replace protest_size = 2 if PartNumbers_low>999&PartNumbers_low<10000 & sample==1
replace protest_size = 3 if PartNumbers_low>9999 & sample==1
tab protest_size

sort protest participants ccode year
replace protest_size = . if participants=="." & PartNumbers_low==50
replace protest_size = . if participants=="" & PartNumbers_low==50



// duration // 
gen edate = mdy(startmonth, startday, startyear)
format edate %d
rename edate DateStart
gen edate = mdy(endmonth, endday, endyear)
format edate %d
rename edate DateEnd

gen duration = (DateEnd - DateStart) + 1
tab duration

gen length = .
replace length = 0 if duration==1 & sample==1
replace length = 1 if duration>1&duration<8 & sample==1
replace length = 2 if duration>7 & sample==1
replace length = . if protest==0 & sample==1
replace length = . if sample==.
tab length

gen disruption_cost_index = disruptionlocation + length + protest_size if sample==1
gen disruption_cost_index_multi = disruptionlocation * length * protest_size if sample==1

*****************************************
*****************************************
//// 3. GENERATE CONCESSION COST VARIABLE
*****************************************
*****************************************

//** Protest Demand Type//
//Labor = 1 
//Land = 2
//Police = 3
//Political = 4
//Price/Tax = 5
//Removal/Corruption = 6
//Social = 7
**//

gen low_threat_demand = .
replace low_threat_demand = 1 if protesterdemand1 == 1
replace low_threat_demand = 1 if protesterdemand1 == 2
replace low_threat_demand = 1 if protesterdemand1 == 5
replace low_threat_demand = 1 if protesterdemand1 == 7
replace low_threat_demand = 1 if protesterdemand2 == 1
replace low_threat_demand = 1 if protesterdemand2 == 2
replace low_threat_demand = 1 if protesterdemand2 == 5
replace low_threat_demand = 1 if protesterdemand2 == 7
replace low_threat_demand = 1 if protesterdemand3 == 1
replace low_threat_demand = 1 if protesterdemand3 == 2
replace low_threat_demand = 1 if protesterdemand3 == 5
replace low_threat_demand = 1 if protesterdemand3 == 7

gen medium_threat_demand = .
replace medium_threat_demand = 1 if protesterdemand1 == 3 
replace medium_threat_demand = 1 if protesterdemand1 == 4 
replace medium_threat_demand = 1 if protesterdemand2 == 3 
replace medium_threat_demand = 1 if protesterdemand2 == 4 
replace medium_threat_demand = 1 if protesterdemand3 == 3 
replace medium_threat_demand = 1 if protesterdemand3 == 4 

gen high_threat_demand = .
replace high_threat_demand = 1 if protesterdemand1 == 6
replace high_threat_demand = 1 if protesterdemand2 == 6
replace high_threat_demand = 1 if protesterdemand3 == 6

gen demand_order = .
replace demand_order = 1 if low_threat_demand==1 & medium_threat_demand==. & high_threat_demand==. & sample==1
replace demand_order = 2 if low_threat_demand==1 & medium_threat_demand == 1 & high_threat_demand == . & sample==1
replace demand_order = 2 if low_threat_demand==. & medium_threat_demand == 1 & high_threat_demand == . & sample==1
replace demand_order = 3 if high_threat_demand == 1 & sample==1
tab demand_order

sort ccode id 
gen samedemand = .
by ccode: replace samedemand = 1 if protesterdemand1[_n-1] == protesterdemand1[_n] 
by ccode: replace samedemand = 1 if protesterdemand1[_n-1] == protesterdemand2[_n] & protesterdemand2!=.
by ccode: replace samedemand = 1 if protesterdemand2[_n-1] == protesterdemand2[_n] & protesterdemand2!=.
by ccode: replace samedemand = 1 if protesterdemand1[_n-1] == protesterdemand3[_n] & protesterdemand3!=.
by ccode: replace samedemand = 1 if protesterdemand2[_n-1] == protesterdemand3[_n] & protesterdemand2!=. & protesterdemand3!=.
by ccode: replace samedemand = 1 if protesterdemand3[_n-1] == protesterdemand3[_n] & protesterdemand3!=.


gen demandhistory = 0 if sample==1
replace demandhistory = 1 if samedemand==1 & sample==1
replace demandhistory = . if protest==0 & sample==1
replace demandhistory = . if ccode[_n]!=ccode[_n-1] & sample==1
tab demandhistory

gen violent = .
replace violent = 1 if protesterviolence==1 & sample==1
replace violent = 0 if protesterviolence==0 & sample==1
tab violent

gen concession_cost_index = demand_order + violent + demandhistory if sample==1
gen concession_cost_index_multi = demand_order * violent * demandhistory if sample==1


****************************************
****************************************
****                                ****
****          Manuscript            ****
****        Figures & Tables        ****
****                                ****
****************************************
****************************************
****************************************

// Figure 1 //
//// PROTEST EVENT DISTRIBUTION BY GEOGRAPHIC REGION ////
gen graph_protest = .
replace graph_protest = ((1396+516+153)/10133) if region==1
replace graph_protest = ((1396+516+153)/10133) if region==2
replace graph_protest = ((1396+516+153)/10133) if region==3
replace graph_protest = ((2359)/10133) if region==4
replace graph_protest = ((2569+34)/10133) if region==5
replace graph_protest = ((2569+34)/10133) if region==8
replace graph_protest = ((1121)/10133) if region==6
replace graph_protest = ((2259)/10133) if region==7

replace graph_protest = graph_protest*100

gen graph_percentobs = .
replace graph_percentobs = ((1430+595+160)/11560) if region==1
replace graph_percentobs = ((1430+595+160)/11560) if region==2
replace graph_percentobs = ((1430+595+160)/11560) if region==3
replace graph_percentobs = (2651/11560) if region==4
replace graph_percentobs = ((2827+42)/11560) if region ==5
replace graph_percentobs = ((2827+42)/11560) if region ==8
replace graph_percentobs = (1121/11560) if region==6
replace graph_percentobs = (2734/11560) if region==7

replace graph_percentobs = graph_percentobs*100

gen region_label = .
replace region_label = 1 if region == 1
replace region_label = 1 if region == 2
replace region_label = 1 if region == 3
replace region_label = 2 if region == 4
replace region_label = 3 if region == 5
replace region_label = 3 if region == 8
replace region_label = 4 if region == 6
replace region_label = 5 if region == 7
tostring region_label, replace force
replace region_label = "Americas" if region_label=="1"
replace region_label = "Europe" if region_label=="2"
replace region_label = "Asia" if region_label == "3"
replace region_label = "MENA" if region_label == "4"
replace region_label = "Africa" if region_label=="5"
encode region_label, generate(graph_region_label)

twoway (bar graph_protest graph_region_label, fcolor(gs12) lcolor(white) barwidth(.5)), ytitle(Percent Protest Events) ylabel(0(3)27, labsize(small) angle(horizontal)) ymtick(0(1)27) xtitle("") xlabel(1(1)5, labsize(small) format(%9.0g) valuelabel) legend(off) graphregion(fcolor(white) lcolor(white))


// Figure 2 //
//// DISTRIBUTION OF STATE RESPONSE ////
**accom=1
**arrests=2
**beat=3
**crowd dis=4
*ignore=5
*kill = 6
*shoot = 7

tab stateresponse1
tab stateresponse2
tab stateresponse3
tab stateresponse4
tab stateresponse5
tab stateresponse6
tab stateresponse7

gen graph_SR = .
//acom//
replace graph_SR = (((652+284+59+49+11+10+2)/13015)*100) if _n==1
//crowd control & arrest//
replace graph_SR = (((795+2573+493+442+178+151+43+27+10+9+1+1)/13015)*100) if _n==2
//deadly & potentially deadly//
replace graph_SR = (((259+195+347+297+228+272+54+134+55+13+32+13+2+5+3+2+1+1)/13015)*100) if _n==3
//disregard//
replace graph_SR = (((5281+23+8)/13015)*100) if _n==4

gen bottom = _n if _n<5
tostring bottom, replace force
replace bottom = "Accommodates" if bottom=="1"
replace bottom = "Crowd Dispersal & Arrests" if bottom == "2"
replace bottom = "Potentially Deadly & Deadly" if bottom=="3"
replace bottom = "Disregard" if bottom == "4"
encode bottom, generate(graph_bottom)

twoway (bar graph_SR graph_bottom, sort fcolor(gs12) barwidth(.5)) if _n<5, ytitle(Percent) ytitle(, size(small)) ylabel(0(5)45, labsize(small) angle(horizontal)) ymtick(0(1)45) xtitle(State Responses) xtitle(, size(small)) xlabel(, labsize(small) format(%9.0g) valuelabel) legend(off) graphregion(fcolor(white) lcolor(white))


// Figure 3 // 
///// DISTRIBUTION OF PROTESTER DEMANDS /////
tab protesterdemand1
tab protesterdemand2
tab protesterdemand3
tab protesterdemand4

gen graph_PD = .
//labor & wage//
replace graph_PD = (((1193+298+37+2)/11803)*100) if _n==1
//land & farm//
replace graph_PD = (((260+65+8+2)/11803)*100) if _n==2
//police brutality//
replace graph_PD = (((577+127+21+1)/11803)*100) if _n==3
//political behavior & process//
replace graph_PD = (((6495+461+26+2)/11803)*100) if _n==4
//price increases & tax policy//
replace graph_PD = (((786+130+83+1)/11803)*100) if _n==5
//removal of politician//
replace graph_PD = (((557+279+32+3)/11803)*100) if _n==6
//social restrictions//
replace graph_PD = (((254+97+6+3)/11803)*100) if _n==7

gen bottom_PD = _n if _n<8
tostring bottom_PD, replace force
replace bottom_PD = "Labor & Wage" if bottom_PD == "1"
replace bottom_PD = "Land & Farm" if bottom_PD == "2"
replace bottom_PD = "Police Abuse" if bottom_PD=="3"
replace bottom_PD = "Political Process" if bottom_PD=="4"
replace bottom_PD = "Tax & Prices" if bottom_PD=="5"
replace bottom_PD = "Corrupt & Resign" if bottom_PD=="6"
replace bottom_PD = "Social Restrict" if bottom_PD == "7"
encode bottom_PD, generate(graph_bottom_PD)

twoway (bar graph_PD graph_bottom_PD, fcolor(gs12) barwidth(.5)) if bottom_PD!=".", ytitle(Percent) ytitle(, size(small)) ylabel(0(5)60, labsize(small) angle(horizontal)) ymtick(0(1)60) xtitle(Protester Demands) xtitle(, size(small)) xlabel(2(1)8, labsize(vsmall) valuelabel) xmtick(2(1)8) graphregion(fcolor(white) lcolor(white))


// Figure 4 //
//// PROTEST VIOLENCE BY PREVIOUS PROTEST VIOLENCE @ TIME T-1 [violence begets violence] ////
sort ccode protest id
by ccode: gen previousviolence = protesterviolence[_n-1]
label define protesterviolence 0 "Non-Violent Protest Time t" 1 "Violent Protest Time t"
histogram protesterviolence if previousviolence==1, percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(10)80, labsize(small) angle(horizontal)) ymtick(0(1)80) xtitle(Violent Protest Time t-1) xlabel(0(1)1, labsize(small) format(%35s) valuelabel) xmtick(0(1)1) graphregion(fcolor(white) lcolor(white)) name(graph_protviol_pv1, replace)
histogram protesterviolence if previousviolence==0, percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(10)80, labsize(small) angle(horizontal)) ymtick(0(1)80) xtitle(Violent Protest Time t-1) xlabel(0(1)1, labsize(small) format(%35s) valuelabel) xmtick(0(1)1) graphregion(fcolor(white) lcolor(white)) name(graph_protviol_npv2, replace)
graph combine graph_protviol_pv1 graph_protviol_npv2, graphregion(fcolor(white) lcolor(white))


// Figure 5 //
//// PROTEST VIOLENCE BY PROTEST DURATION ////
histogram protesterviolence if duration==1, percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(10)80, labsize(small) angle(horizontal)) ymtick(0(1)80) xtitle(One Day Protest Events) xlabel(0(1)1, labsize(small) format(%35s) valuelabel) xmtick(0(1)1) graphregion(fcolor(white) lcolor(white)) name(oneday, replace)
histogram protesterviolence if duration>1 & duration!=., percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(10)80, labsize(small) angle(horizontal)) ymtick(0(1)80) xtitle(Multi-Day Protest Events) xlabel(0(1)1, labsize(small) format(%35s) valuelabel) xmtick(0(1)1) graphregion(fcolor(white) lcolor(white)) name(multiday, replace)
graph combine oneday multiday, graphregion(fcolor(white) lcolor(white))


// Figure 6 //
//// PROTEST VIOLENCE BY PREVIOUS VIOLENCE @ TIME T-1 & PROTEST DURATION ////
histogram protesterviolence if previousviolence==1 & duration==1, percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(10)80, labsize(small) angle(horizontal)) ymtick(0(1)80) xtitle(One Day Protest Events) xlabel(0(1)1, labsize(small) format(%35s) valuelabel) xmtick(0(1)1) graphregion(fcolor(white) lcolor(white)) name(onedaypv1, replace)
histogram protesterviolence if previousviolence==1 & duration>1 & duration!=., percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(10)80, labsize(small) angle(horizontal)) ymtick(0(1)80) xtitle(Multi-Day Protest Events) xlabel(0(1)1, labsize(small) format(%35s) valuelabel) xmtick(0(1)1) graphregion(fcolor(white) lcolor(white)) name(multidaypv1, replace)
histogram protesterviolence if previousviolence==0 & duration==1, percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(10)80, labsize(small) angle(horizontal)) ymtick(0(1)80) xtitle(One Day Protest Events) xlabel(0(1)1, labsize(small) format(%35s) valuelabel) xmtick(0(1)1) graphregion(fcolor(white) lcolor(white)) name(onedaynpv1, replace)
histogram protesterviolence if previousviolence==0 & duration>1 & duration!=., percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(10)80, labsize(small) angle(horizontal)) ymtick(0(1)80) xtitle(Multi-Day Protest Events) xlabel(0(1)1, labsize(small) format(%35s) valuelabel) xmtick(0(1)1) graphregion(fcolor(white) lcolor(white)) name(multidaynpv1, replace)
graph combine onedaypv1 multidaypv1 onedaynpv1 multidaynpv1, graphregion(fcolor(white) lcolor(white))


// Figure 7 //
//// VIOLENCE AND THE RANGE & DISTRIBUTION OF ALTERNATIVE CONCESSION COST INDEX SPECIFICATIONS ////
gen cci_noviolence = demand_order + demandhistory if sample==1
replace cci_noviolence = . if protest==0
replace cci_noviolence = . if protesterviolence==.

histogram concession_cost_index, percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(5)55, labsize(small) angle(horizontal)) ymtick(0(1)55) xtitle("") xlabel(1(1)5, labsize(small)) xmtick(1(1)5) title(With Violence Component) graphregion(fcolor(white) lcolor(white)) name(ConCostViolence, replace)
histogram cci_noviolence, percent fcolor(gs12) lcolor(white) barwidth(.5) ytitle(Percent) ytitle(, size(small)) ylabel(0(5)55, labsize(small) angle(horizontal)) ymtick(0(1)55) xtitle("") xlabel(1(1)5, labsize(small)) xmtick(1(1)5) title(Without Violence Component) graphregion(fcolor(white) lcolor(white)) name(ConCostNoViolence, replace)
graph combine ConCostViolence ConCostNoViolence, graphregion(fcolor(white) lcolor(white)) note(Concession Costs Index, size(small) position(6))


// Table 2 //
////// MULTINOMIAL LOGIT REGRESSION RESULTS /////
sort ccode id
gen last2violent = 0 & sample == 1
by ccode: replace last2violent = 1 if protesterviolence[_n-2]==1 & sample == 1
by ccode: replace last2violent = 1 if protesterviolence[_n-1]==1 & sample == 1

gen number_of_demands = 1 if protesterdemand1!=. & sample==1
replace number_of_demands = 2 if protesterdemand2!=. & sample==1
replace number_of_demands = 3 if protesterdemand3!=. & sample==1

// Model 1 //
mlogit state_response disruption_cost_index concession_cost_index, cluster(ccode) 

// Model 2 //
mlogit state_response disruption_cost_index concession_cost_index polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode) 

// Model 3 // 
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands, cluster(ccode)

// Model 4 // 
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode)

// Hausman Base test & Seemingly Unrelated Estimation Tests for i.i.a //
mlogit state_response disruption_cost_index concession_cost_index polity2 polity2_squared ln_gdppercap Youth_Bulge 
estimates store m1, title(all four response types)
quietly mlogit state_response disruption_cost_index concession_cost_index polity2 polity2_squared ln_gdppercap Youth_Bulge if state_response!=2
estimates store m2, title(state_response!= "crowd": state_response) 
quietly mlogit state_response disruption_cost_index concession_cost_index polity2 polity2_squared ln_gdppercap Youth_Bulge if state_response!=3 
estimates store m3, title(state_response!= "accom": state_response) 
quietly mlogit state_response disruption_cost_index concession_cost_index polity2 polity2_squared ln_gdppercap Youth_Bulge if state_response!=4 
estimates store m4, title(state_response!= "coercion": state_response) 
estimates dir
estimates table m1 m2 m3 m4, star stats(N ll)
hausman m2 m1, alleqs constant
hausman m3 m1, alleqs constant
hausman m4 m1, alleqs constant
hausman m2 m3, alleqs constant
hausman m2 m4, alleqs constant
hausman m3 m4, alleqs constant

suest m*, vce(cluster ccode) noomitted
test[m1_2 = m3_2], cons
test[m1_2 = m4_2], cons
test[m1_3 = m2_3], cons
test[m1_3 = m4_3], cons
test[m1_4 = m2_4], cons
test[m1_4 = m3_4], cons
test[m2_3 = m4_3], cons
test[m2_4 = m3_4], cons
test[m3_2 = m4_2], cons


mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands 
estimates store m1, title(all four response types)
quietly mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands if state_response!=2
estimates store m2, title(state_response!= "crowd": state_response) 
quietly mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands if state_response!=3 
estimates store m3, title(state_response!= "accom": state_response) 
quietly mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands if state_response!=4 
estimates store m4, title(state_response!= "coercion": state_response) 
estimates dir
estimates table m1 m2 m3 m4, star stats(N ll)
hausman m2 m1, alleqs constant
hausman m3 m1, alleqs constant
hausman m4 m1, alleqs constant
hausman m2 m3, alleqs constant
hausman m2 m4, alleqs constant
hausman m3 m4, alleqs constant

suest m*, vce(cluster ccode) noomitted
test[m1_2 = m3_2], cons
test[m1_2 = m4_2], cons
test[m1_3 = m2_3], cons
test[m1_3 = m4_3], cons
test[m1_4 = m2_4], cons
test[m1_4 = m3_4], cons
test[m2_3 = m4_3], cons
test[m2_4 = m3_4], cons
test[m3_2 = m4_2], cons


mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge
estimates store m1, title(all four response types)
quietly mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if state_response!=2
estimates store m2, title(state_response!= "crowd": state_response) 
quietly mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if state_response!=3 
estimates store m3, title(state_response!= "accom": state_response) 
quietly mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if state_response!=4 
estimates store m4, title(state_response!= "coercion": state_response) 
estimates dir
estimates table m1 m2 m3 m4, star stats(N ll)
hausman m2 m1, alleqs constant
hausman m3 m1, alleqs constant
hausman m4 m1, alleqs constant
hausman m2 m3, alleqs constant
hausman m2 m4, alleqs constant
hausman m3 m4, alleqs constant

suest m*, vce(cluster ccode) noomitted
test[m1_2 = m3_2], cons
test[m1_2 = m4_2], cons
test[m1_3 = m2_3], cons
test[m1_3 = m4_3], cons
test[m1_4 = m2_4], cons
test[m1_4 = m3_4], cons
test[m2_3 = m4_3], cons
test[m2_4 = m3_4], cons
test[m3_2 = m4_2], cons


// Figure 8 //
////// PREDICTEd PROBABILITY OF STATE RESPONSE ACROSS CONCESSION COSTS INDEX /////
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode)
sum state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if e(sample)

prgen concession_cost_index, generate(k) f(1) t(5) n(5) ci x(disruption_cost_index 4 polity2 14.35 polity2_squared 205.93 ln_gdppercap 7.878 Youth_Bulge 17.947 last2violent 0 number_of_demands 1)
twoway (rarea kp1lb kp1ub kx, fcolor(gs6) lcolor(gs6) lwidth(none)) (rarea kp2lb kp2ub kx, fcolor(gs14) lcolor(gs14) lwidth(none)) (rarea kp3lb kp3ub kx, fcolor(gs8) lcolor(gs8) lwidth(none)) (rarea kp4lb kp4ub kx, fcolor(gs10) lcolor(gs10) lwidth(none)) (connected kp1 kx, msymbol(O) mcolor(black) msize(small) lcolor(none)) (connected kp2 kx, msymbol(S) mcolor(black) msize(small) lcolor(none)) (connected kp3 kx, msymbol(T) msize(small) mcolor(black) lcolor(none)) (connected kp4 kx, msymbol(D) mcolor(black) msize(small) lcolor(none)), legend(rowgap(0) keygap(0) order(5 6 7 8) label(5 "Disregard") label(6 "Crowd Control") label(7 "Accommodation") label(8 "Coercion")) xtitle(Concession Costs Index) ytitle(Predicted Probability of Each State Response (%)) ytitle(, size(small)) ylabel(0(.05).80, labsize(vsmall) angle(horizontal)) ymtick(0(.01).80) graphregion(fcolor(white) lcolor(white))


// Figure 9 //
/////// PREDICTED PROBABILITY OF STATE RESPONSE ACROSS DISRUPTION COSTS INDEX /////
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode)

prgen disruption_cost_index, generate(r) f(1) t(9) n(9) ci x(concession_cost_index 3 polity2 14.35 polity2_squared 205.93 ln_gdppercap 7.878 Youth_Bulge 17.948 last2violent 0 number_of_demands 1)
twoway (rarea rp2lb rp2ub rx, fcolor(gs14) lcolor(gs14) lwidth(none)) (rarea rp3lb rp3ub rx, fcolor(gs7) lcolor(gs7) lwidth(none)) (rarea rp4lb rp4ub rx, fcolor(gs11) lcolor(gs11) lwidth(none)) (connected rp2 rx, msymbol(S) mcolor(black) msize(small) lcolor(none)) (connected rp3 rx, msymbol(T) msize(small) mcolor(black) lcolor(none)) (connected rp4 rx, msymbol(D) mcolor(black) msize(small) lcolor(none)), legend(row(1) rowgap(0) keygap(0) order(4 5 6) label(4 "Crowd Control") label(5 "Accommodation") label(6 "Coercion")) xtitle(Disruption Costs Index) xtitle(, size(small)) xlabel(1(1)9, labsize(vsmall) angle(horizontal)) ytitle(Predicted Probability of Each State Response (%)) ytitle(, size(small)) ylabel(0(.05).45, labsize(vsmall) angle(horizontal)) ymtick(0(.01).45) graphregion(fcolor(white) lcolor(white))

prvalue if sample==1, x(concession_cost_index = 5 polity2 = 14.35 polity2_squared = 205.93 last2violent = 0 number_of_demands = 1) rest(mean)
prvalue if sample==1, x(disruption_cost_index = 9 polity2 = 14.35 polity2_squared = 205.93 last2violent = 0 number_of_demands = 1) rest(mean)
prvalue if sample==1, x(concession_cost_index = 5 disruption_cost_index = 9 polity2 = 14.35 polity2_squared = 205.93 last2violent = 0 number_of_demands = 1) rest(mean)
prvalue if sample==1, x(concession_cost_index = 1 disruption_cost_index = 1 polity2 = 14.35 polity2_squared = 205.93 last2violent = 0 number_of_demands = 1) rest(mean)
prvalue if sample==1, x(concession_cost_index = 1 disruption_cost_index = 9 polity2 = 14.35 polity2_squared = 205.93 last2violent = 0 number_of_demands = 1) rest(mean)
prvalue if sample==1, x(concession_cost_index = 5 disruption_cost_index = 1 polity2 = 14.35 polity2_squared = 205.93 last2violent = 0 number_of_demands = 1 ) rest(mean)
prvalue if sample==1, x(concession_cost_index = 5 disruption_cost_index = 4 polity2 = 14.35 polity2_squared = 205.93 last2violent = 0 number_of_demands = 1) rest(mean)
prvalue if sample==1, x(concession_cost_index = 3 disruption_cost_index = 9 polity2 = 14.35 polity2_squared = 205.93 last2violent = 0 number_of_demands = 1) rest(mean)


// Table 3 //
/////// MULTINOMIAL LOGIT REGRESSION RESULTS, MIXED RESPONSE CATEGORY INCLUDED ///////
gen mixed_response = .
replace mixed_response = 1 if stateresponse1 == 5 & stateresponse2==.
replace mixed_response = 2 if stateresponse1 == 2 & stateresponse2==.
replace mixed_response = 2 if stateresponse1 == . & stateresponse2==4
replace mixed_response = 2 if stateresponse1 == 2 & stateresponse2==4 & stateresponse3==.
replace mixed_response = 2 if stateresponse1 == 4 & stateresponse2==.
replace mixed_response = 2 if stateresponse1 == 4 & stateresponse2==2 & stateresponse3==.
replace mixed_response = 3 if stateresponse1 == 1 & stateresponse2==.
replace mixed_response = 4 if stateresponse1 == 3 & stateresponse2==.
replace mixed_response = 4 if stateresponse1 == 3 & stateresponse2==6 & stateresponse3==.
replace mixed_response = 4 if stateresponse1 == 3 & stateresponse2==6 & stateresponse3==7
replace mixed_response = 4 if stateresponse1 == 3 & stateresponse2==7 & stateresponse3==.
replace mixed_response = 4 if stateresponse1 == 3 & stateresponse2==7 & stateresponse3==6
replace mixed_response = 4 if stateresponse1 == 6 & stateresponse2==.
replace mixed_response = 4 if stateresponse1 == 6 & stateresponse2==3 & stateresponse3==.
replace mixed_response = 4 if stateresponse1 == 6 & stateresponse2==3 & stateresponse3==7
replace mixed_response = 4 if stateresponse1 == 6 & stateresponse2==7 & stateresponse3==.
replace mixed_response = 4 if stateresponse1 == 6 & stateresponse2==7 & stateresponse3==3
replace mixed_response = 4 if stateresponse1 == 7 & stateresponse2==.
replace mixed_response = 4 if stateresponse1 == 7 & stateresponse2==6 & stateresponse3==.
replace mixed_response = 4 if stateresponse1 == 7 & stateresponse2==6 & stateresponse3==3
replace mixed_response = 4 if stateresponse1 == 7 & stateresponse2==3 & stateresponse3==.
replace mixed_response = 4 if stateresponse1 == 7 & stateresponse2==3 & stateresponse3==6
replace mixed_response = 4 if stateresponse1 == 6 &stateresponse2==6
replace mixed_response = 4 if stateresponse1 == . &stateresponse2==3
replace mixed_response = 5 if stateresponse1 == 5 & stateresponse2!=.
replace mixed_response = 5 if stateresponse1 == 2 & stateresponse2==1
replace mixed_response = 5 if stateresponse1 == 2 & stateresponse2==3
replace mixed_response = 5 if stateresponse1 == 2 & stateresponse2==5
replace mixed_response = 5 if stateresponse1 == 2 & stateresponse2==6
replace mixed_response = 5 if stateresponse1 == 2 & stateresponse2==7
replace mixed_response = 5 if stateresponse1 == 2 & stateresponse2==4 & stateresponse3!=.
replace mixed_response = 5 if stateresponse1 == 4 & stateresponse2==1
replace mixed_response = 5 if stateresponse1 == 4 & stateresponse2==3
replace mixed_response = 5 if stateresponse1 == 4 & stateresponse2==5
replace mixed_response = 5 if stateresponse1 == 4 & stateresponse2==6
replace mixed_response = 5 if stateresponse1 == 4 & stateresponse2==7
replace mixed_response = 5 if stateresponse1 == 4 & stateresponse2==2 & stateresponse3!=.
replace mixed_response = 5 if stateresponse1 == 1 & stateresponse2!=.
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==1
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==2
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==4
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==6 & stateresponse3==1
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==6 & stateresponse3==2
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==6 & stateresponse3==4
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==7 & stateresponse3==1
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==7 & stateresponse3==2
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==7 & stateresponse3==4
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==6 & stateresponse3==7 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==6 & stateresponse3==7 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==6 & stateresponse3==7 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==7 & stateresponse3==6 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==7 & stateresponse3==6 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 3 & stateresponse2==7 & stateresponse3==6 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==1
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==2
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==4
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==3 & stateresponse3==1
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==3 & stateresponse3==2
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==3 & stateresponse3==4
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==7 & stateresponse3==1
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==7 & stateresponse3==2
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==7 & stateresponse3==4
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==3 & stateresponse3==7 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==3 & stateresponse3==7 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==3 & stateresponse3==7 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==7 & stateresponse3==3 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==7 & stateresponse3==3 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 6 & stateresponse2==7 & stateresponse3==3 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==1
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==2
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==4
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==6 & stateresponse3==1
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==6 & stateresponse3==2
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==6 & stateresponse3==4
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==3 & stateresponse3==1
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==3 & stateresponse3==2
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==3 & stateresponse3==4
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==6 & stateresponse3==3 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==6 & stateresponse3==3 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==6 & stateresponse3==3 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==3 & stateresponse3==6 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==3 & stateresponse3==6 & stateresponse4!=.
replace mixed_response = 5 if stateresponse1 == 7 & stateresponse2==3 & stateresponse3==6 & stateresponse4!=.

// Model 5 //
mlogit mixed_response disruption_cost_index concession_cost_index, cluster(ccode)

// Model 6 //
mlogit mixed_response disruption_cost_index concession_cost_index polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode)

// Model 7 //
mlogit mixed_response disruption_cost_index concession_cost_index last2violent number_of_demands, cluster(ccode)

// Model 8 //
mlogit mixed_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode)


// Table 4 //
////// FIXED EFFECTS MULTINOMIAL LOGIT REGRESSION RESULTS, COST INDICES ONLY ///////
// Model 9 //
xtset ccode 
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode)
tab ccode if e(sample)
gen testsample = 1 if e(sample)
tab testsample
gen testsample4 = testsample
// <3 protest //
replace testsample4=. if ccode==51
replace testsample4=. if ccode==402
replace testsample4=. if ccode==531
replace testsample4=. if ccode==694
replace testsample4=. if ccode==760
replace testsample4=. if ccode==812

mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge i.ccode if testsample4==1, vce(robust)



****************************************
****************************************
****                                ****
****        Online Appendix         ****
****        Figures & Tables        ****
****                                ****
****************************************
****************************************
****************************************


// Table A1 //
///// DESCRIPTIVE STATISTICS OF "RAW" PROTEST EVENT DATA /////
sum duration PartNumbers_low protesterviolence disruptionlocation
tab protesterdemand1
tab protesterdemand2
tab protesterdemand3
tab stateresponse1
tab stateresponse2
tab stateresponse3


// Table A2 //
//////   COST INDICES CORRELATION MATRIX   ////
sort ccode protest id
by ccode: gen previous_SR = state_response[_n-1]
by ccode: gen previous_CCI = concession_cost_index[_n-1]
by ccode: gen previous_DCI = disruption_cost_index[_n-1]
by ccode: replace previousviolence = protesterviolence[_n-1] if protest==1
by ccode: gen previousviolence2 = .
by ccode: replace previousviolence2 = protesterviolence[_n-2] if protest==1

corr concession_cost_index disruption_cost_index previous_CCI previous_DCI previous_SR previousviolence


//  Table A3  //
//////   DETERMINANTS OF CONCESSION COSTS INDEX(t) [ORDERED LOGIT]  //////

// Model A1 //
ologit concession_cost_index previous_SR disruption_cost_index, cluster(ccode)
// Model A2 //
ologit concession_cost_index disruption_cost_index previous_DCI previous_CCI, cluster(ccode)
// Model A3 //
ologit concession_cost_index previous_SR  disruption_cost_index number_of_demands previousviolence region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)
// Model A4 //
ologit concession_cost_index previous_DCI previous_CCI disruption_cost_index previousviolence number_of_demands region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)


// Table A4 //
//////   DETERMINANTS OF DISRUPTION COSTS INDEX(t) [ORDERED LOGIT]  //////

// Model A5 //
ologit disruption_cost_index previous_SR concession_cost_index, cluster(ccode)
// Model A6 //
ologit disruption_cost_index concession_cost_index previous_DCI previous_CCI, cluster(ccode)
// Model A7 //
ologit disruption_cost_index previous_SR concession_cost_index number_of_demands previousviolence region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)
// Model A8 //
ologit disruption_cost_index previous_DCI previous_CCI concession_cost_index number_of_demands previousviolence region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)


// Table A5 //
/////  VIOLENCE BEGETS VIOLENCE, ALL PROTESTS [LOGIT]  /////
gen test_accommodate = accommodate
replace test_accommodate = 0 if accommodate ==.
replace test_accommodate = . if protest==0
sort ccode year protestnumber startday
by ccode: gen test_accom_lag = test_accommodate[_n-1]
by ccode: replace test_accom_lag = test_accom_lag[_n-1] if missing(test_accom_lag)

gen test_police = police
replace test_police = 0 if police==.
replace test_police = . if protest==0
sort ccode year protestnumber startday
by ccode: gen test_police_lag = test_police[_n-1]
by ccode: replace test_police_lag = test_police_lag[_n-1] if missing(test_police_lag)

gen test_disregard = disregard
replace test_disregard = 0 if disregard==.
replace test_disregard = . if protest ==0
sort ccode year protestnumber startday
by ccode: gen test_disregard_lag = test_disregard[_n-1]
by ccode: replace test_disregard_lag = test_disregard_lag[_n-1] if missing(test_disregard_lag)

gen test_coercion = coercion
replace test_coercion = 0 if coercion==.
replace test_coercion = . if protest==0
sort ccode year protestnumber startday
by ccode: gen test_coercion_lag = test_coercion[_n-1]
by ccode: replace test_coercion_lag = test_coercion_lag[_n-1] if missing(test_coercion_lag)

//  Model A9  //
logit protesterviolence previousviolence previous_SR duration demand_order number_of_demands demandhistory, cluster(ccode)
//  Model A10  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order number_of_demands demandhistory, cluster(ccode)
//  Model A11  //
logit protesterviolence previousviolence previous_SR duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory, cluster(ccode)
//  Model A12  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory, cluster(ccode)
//  Model A13  //
logit protesterviolence previousviolence test_coercion_lag test_accom_lag test_police_lag test_disregard_lag duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory, cluster(ccode)


// Table A6 //
/////  VIOLENCE BEGETS VIOLENCE, ONE-DAY PROTESTS [LOGIT]  /////

//  Model A14  //
logit protesterviolence previousviolence previous_SR demand_order number_of_demands demandhistory if duration==1, cluster(ccode)
//  Model A15  //
logit protesterviolence previousviolence previous_DCI previous_CCI demand_order number_of_demands demandhistory if duration==1, cluster(ccode)
//  Model A16  //
logit protesterviolence previousviolence previous_SR demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if duration==1, cluster(ccode)
//  Model A17  //
logit protesterviolence previousviolence previous_DCI previous_CCI demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if duration==1, cluster(ccode)
//  Model A18  //
logit protesterviolence previousviolence test_coercion_lag test_accom_lag test_police_lag test_disregard_lag demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if duration==1, cluster(ccode)


// Table A7 //
/////  VIOLENCE BEGETS VIOLENCE, MULTI-DAY PROTESTS [LOGIT]  /////

//  Model A19  //
logit protesterviolence previousviolence previous_SR duration demand_order number_of_demands demandhistory if duration>1&duration!=., cluster(ccode)
//  Model A20  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order number_of_demands demandhistory if duration>1&duration!=., cluster(ccode)
//  Model A21  //
logit protesterviolence previousviolence previous_SR duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if duration>1&duration!=., cluster(ccode)
//  Model A22  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if duration>1&duration!=., cluster(ccode)
//  Model A23  //
logit protesterviolence previousviolence test_coercion_lag test_accom_lag test_police_lag test_disregard_lag duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if duration>1&duration!=., cluster(ccode)


//  Table A8  //
/////  VIOLENCE BEGETS VIOLENCE, SEQUENTIAL PROTESTS [LOGIT]  /////
gen time_between_events = .
sort ccode protest id
by ccode: replace time_between_events = DateStart - DateEnd[_n-1]
replace time_between_events = 0 if time_between_events<0&time_between_events!=.
tab time_between_events
sum time_between_events, detail
gen sequential_event = 0
replace sequential_event = 1 if time_between_events<22 & time_between_events!=.
gen isolated_event = 0 
replace isolated_event = 1 if time_between_events>21 & time_between_events!=. 
tab time_between_events if sequential_event == 1
tab time_between_events if isolated_event==1

//  Model A24  //
logit protesterviolence previousviolence previous_SR duration demand_order number_of_demands demandhistory if sequential_event==1, cluster(ccode)
//  Model A25  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order number_of_demands demandhistory if sequential_event==1, cluster(ccode)
//  Model A26  //
logit protesterviolence previousviolence previous_SR duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if sequential_event==1, cluster(ccode)
//  Model A27  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if sequential_event==1, cluster(ccode)
//  Model A28  //
logit protesterviolence previousviolence test_coercion_lag test_accom_lag test_police_lag test_disregard_lag duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if sequential_event==1, cluster(ccode)


//  Table A9  //
/////  VIOLENCE BEGETS VIOLENCE, ISOLATED PROTESTS [LOGIT]  /////

//  Model A29  //
logit protesterviolence previousviolence previous_SR duration demand_order number_of_demands demandhistory if isolated_event==1, cluster(ccode)
//  Model A30  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order number_of_demands demandhistory if isolated_event==1, cluster(ccode)
//  Model A31  //
logit protesterviolence previousviolence previous_SR duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if isolated_event==1, cluster(ccode)
//  Model A32  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if isolated_event==1, cluster(ccode)
//  Model A33  //
logit protesterviolence previousviolence test_coercion_lag test_accom_lag test_police_lag test_disregard_lag duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands demandhistory if isolated_event==1, cluster(ccode)


//  Table A10  //
/////  VIOLENCE BEGETS VIOLENCE, RECURRENT DEMAND PROTESTS [LOGIT]  /////
gen recurrent_event = 0
replace recurrent_event = 1 if demandhistory == 1
gen disassociated_event = 0
replace disassociated_event = 1 if demandhistory == 0

//  Model A34  //
logit protesterviolence previousviolence previous_SR duration demand_order number_of_demands if recurrent_event==1, cluster(ccode)
//  Model A35  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order number_of_demands if recurrent_event==1, cluster(ccode)
//  Model A36  //
logit protesterviolence previousviolence previous_SR duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands if recurrent_event==1, cluster(ccode)
//  Model A37  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands if recurrent_event==1, cluster(ccode)
//  Model A38  //
logit protesterviolence previousviolence test_coercion_lag test_accom_lag test_police_lag test_disregard_lag duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands if recurrent_event==1, cluster(ccode)


//  Table A11  //
/////  VIOLENCE BEGETS VIOLENCE, DISASSOCIATED PROTESTS [LOGIT]  /////

//  Model A39  //
logit protesterviolence previousviolence previous_SR duration demand_order number_of_demands if disassociated_event==1, cluster(ccode)
//  Model A40  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order number_of_demands if disassociated_event==1, cluster(ccode)
//  Model A41  //
logit protesterviolence previousviolence previous_SR duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands if disassociated_event==1, cluster(ccode)
//  Model A42  //
logit protesterviolence previousviolence previous_DCI previous_CCI duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands if disassociated_event==1, cluster(ccode)
//  Model A43  //
logit protesterviolence previousviolence test_coercion_lag test_accom_lag test_police_lag test_disregard_lag duration demand_order region polity2 polity2_squared Youth_Bulge ln_gdppercap number_of_demands if disassociated_event==1, cluster(ccode)


// Table A12 //
/////  RECURRENT DEMAND [LOGIT]  /////
sort ccode protest id
by ccode: gen demandtype_lag = demand_order[_n-1]
by ccode: replace demandtype_lag = demandtype_lag[_n-1] if missing(demandtype_lag)
gen demand_type_square = demand_order * demand_order
sort ccode protest id
by ccode: gen demand_type_square_lag = demand_type_square[_n-1]
by ccode: replace demand_type_square_lag = demand_type_square_lag[_n-1] if missing(demand_type_square_lag)

//  Model A44  //
logit demandhistory previous_SR demandtype_lag previousviolence number_of_demands region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)
//  Model A45  //
logit demandhistory test_coercion_lag test_accom_lag test_police_lag test_disregard_lag demandtype_lag previousviolence number_of_demands region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)
//  Model A46  //
logit demandhistory previous_SR demandtype_lag demand_type_square_lag previousviolence number_of_demands region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)
//  Model A47  //
logit demandhistory test_coercion_lag test_accom_lag test_police_lag test_disregard_lag demandtype_lag demand_type_square_lag previousviolence  number_of_demands region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)


// Figure A1 //
////// MARGINAL EFFECT OF DEMAND TYPE(t-1) on RECURRENT DEMAND(t) /////

//  Model A47  //
logit demandhistory test_coercion_lag test_accom_lag test_police_lag test_disregard_lag demandtype_lag demand_type_square_lag previousviolence  number_of_demands region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)
margins, over(demandtype_lag)
marginsplot, graphregion(fcolor(white) lcolor(white)) title("") xtitle(Demand Type (t-1)) xtitle(, size(small)) xlabel(1(1)3, valuelabel labsize(small)) ytitle(Predicted Probability of Recurrent Demand (%)) ytitle(, size(small)) ylabel(0(.1)1, labsize(small) angle(horizontal))


// Table A13 //
///// COSTS INDICES COMPARISONS /////
corr concession_cost_index concession_cost_index_multi disruption_cost_index disruption_cost_index_multi
tab concession_cost_index 
tab concession_cost_index_multi
tab disruption_cost_index 
tab disruption_cost_index_multi 


// TABLE A14 //
///// CONCESSION COSTS INDICES COMPARISONS /////
gen W1_add_con_cost = (demand_order * .5) + (violent * .25) + (demandhistory * .25)
gen W2_add_con_cost = (demand_order * .25) + (violent * .5) + (demandhistory * .25)
gen W3_add_con_cost = (demand_order * .25) + (violent * .25) + (demandhistory * .5)
gen W4_add_con_cost = (demand_order * .8) + (violent * .15) + (demandhistory * .05)
gen W5_multi_con_cost = (demand_order * .8) * (violent * .15) * (demandhistory * .05)

corr concession_cost_index concession_cost_index_multi W1_add_con_cost W2_add_con_cost W3_add_con_cost W4_add_con_cost W5_multi_con_cost if sample==1


// TABLE A15 //
///// DISTRIBUTION OF CONCESSION COSTS INDICES /////
tab concession_cost_index 
tab W1_add_con_cost if concession_cost_index!=.
tab W2_add_con_cost if concession_cost_index!=. 
tab W3_add_con_cost if concession_cost_index!=. 
tab W4_add_con_cost if concession_cost_index!=. 
tab concession_cost_index_multi 
tab W5_multi_con_cost if concession_cost_index!=. 


// TABLE A16 //
///// DISTRIBUTION COSTS INDICES COMPARISONS /////
gen W1_add_dis_cost = (protest_size *.5) + (disruptionlocation * .25) + (length * .25)
gen W2_add_dis_cost = (protest_size *.25) + (disruptionlocation * .5) + (length * .25)
gen W3_add_dis_cost = (protest_size *.25) + (disruptionlocation * .25) + (length * .5)
gen W4_add_dis_cost = (protest_size *.8) + (disruptionlocation * .15) + (length * .05)
gen W5_multi_dis_cost = (protest_size *.8) * (disruptionlocation * .15) * (length * .05)

corr disruption_cost_index disruption_cost_index_multi W1_add_dis_cost W2_add_dis_cost W3_add_dis_cost W4_add_dis_cost W5_multi_dis_cost if sample==1


// TABLE A17 //
///// DISTRIBUTION OF DISRUPTION COSTS INDICES /////
tab disruption_cost_index
tab W1_add_dis_cost if disruption_cost_index!=.
tab W2_add_dis_cost if disruption_cost_index!=.
tab W3_add_dis_cost if disruption_cost_index!=.
tab W4_add_dis_cost if disruption_cost_index!=.
tab disruption_cost_index_multi
tab W5_multi_dis_cost if disruption_cost_index!=.


// Table A18 //
///// DISTRIBUTION OF COMPETING CONCESSION COST INDEX SPECIFICATIONS /////
tab concession_cost_index
tab concession_cost_index if violent==1
tab concession_cost_index if violent==0
gen concession_cost_index3 = demand_order + demandhistory
tab concession_cost_index3


// Table A19  //
///// DESCRIPTIVE STATISTICS FOR STATE RESPONSE MODELS /////
sum duration PartNumbers_low protesterviolence disruptionlocation
tab protesterdemand1
tab protesterdemand2
tab protesterdemand3
tab stateresponse1
tab stateresponse2
tab stateresponse3


// Table 20  //
///// PROTEST SAMPLE SELECTION [LOGIT REGRESSION] /////
sort ccode year protest protestnumber startday
by ccode: gen protestnumber_lag = protestnumber[_n-1]
by ccode: gen protest_lag = protest[_n-1]
gen PHYSINT_SQUARED = PHYSINT * PHYSINT

//  Model A48  //
logit protest PHYSINT polity2 ln_gdppercap Youth_Bulge region, cluster(ccode)
//  Model A49  //
logit protest PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region, cluster(ccode)
//  Model A50  //
logit protest PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protest_lag, cluster(ccode)
//  Model A51  //
logit protest PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protest_lag test_accom_lag test_coercion_lag test_police_lag, cluster(ccode)


// Table 21 //
///// PROTEST SAMPLE SELECTION [ZERO INFLATED NEGATIVE BINOMIAL REGRESSION] /////
gen ProtestCount = 0 if protest == 0
replace ProtestCount = protestnumber if year[_n]!=year[_n+1]

//  Model A52  //
zinb ProtestCount PHYSINT polity2 ln_gdppercap Youth_Bulge region, inflate(PHYSINT polity2 ln_gdppercap Youth_Bulge region) cluster(ccode)
zinb ProtestCount PHYSINT polity2 ln_gdppercap Youth_Bulge region, inflate(PHYSINT polity2 ln_gdppercap Youth_Bulge region) vuong
//  Model A53  //
zinb ProtestCount PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region, inflate(PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region) cluster(ccode)
zinb ProtestCount PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region, inflate(PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region) vuong
//  Model A54  //
zinb ProtestCount PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protestnumber_lag , inflate(PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protestnumber_lag ) cluster(ccode)
zinb ProtestCount PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protestnumber_lag , inflate(PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protestnumber_lag ) vuong

sort ccode year protest protestnumber startday
bysort ccode year: gen accom_count = sum(test_accommodate)
bysort ccode year: gen police_count = sum(test_police)
bysort ccode year: gen coerce_count = sum(test_coercion)
bysort ccode year: gen disregard_count = sum(test_disregard)
sort ccode year protest protestnumber startday
by ccode: gen accom_count_lag = accom_count[_n-1] if ProtestCount[_n-1]!=.
by ccode: replace accom_count_lag = accom_count_lag[_n-1] if missing(accom_count_lag)
by ccode: gen police_count_lag = police_count[_n-1] if ProtestCount[_n-1]!=.
by ccode: replace police_count_lag = police_count_lag[_n-1] if missing(police_count_lag)
by ccode: gen coerce_count_lag = coerce_count[_n-1] if ProtestCount[_n-1]!=.
by ccode: replace coerce_count_lag = coerce_count_lag[_n-1] if missing(coerce_count_lag)
by ccode: gen disregard_count_lag = disregard_count[_n-1] if ProtestCount[_n-1]!=.
by ccode: replace disregard_count_lag = disregard_count_lag[_n-1] if missing(disregard_count_lag)

//  Model A55  //
zinb ProtestCount PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protestnumber_lag accom_count_lag police_count_lag coerce_count_lag, inflate(PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protestnumber_lag accom_count_lag police_count_lag coerce_count_lag) cluster(ccode)
zinb ProtestCount PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protestnumber_lag accom_count_lag police_count_lag coerce_count_lag, inflate(PHYSINT PHYSINT_SQUARED polity2 polity2_squared ln_gdppercap Youth_Bulge region protestnumber_lag accom_count_lag police_count_lag coerce_count_lag) vuong


// TABLE 22 //
////// DESCRIPTIVE STATISTICS FOR ROBUSTNESS CHECKS  /////
// Table 26 - Alternative Disruption Cost Index //
sort ccode id
by ccode: gen time_since_protest = DateStart - DateEnd[_n-1] if sample!=.
tab time_since_protest
sum time_since_protest, detail
replace time_since_protest = 0 if time_since_protest<0
tab time_since_protest
sum time_since_protest, detail
gen recent_protest = .
replace recent_protest = 5 if time_since_protest == 0 & sample==1      
replace recent_protest = 4 if time_since_protest>0&time_since_protest<8&sample==1
replace recent_protest = 3 if time_since_protest>7&time_since_protest<31&sample==1 
replace recent_protest = 2 if time_since_protest>31&time_since_protest<63&sample==1
replace recent_protest = 1 if time_since_protest>63&time_since_protest<187&sample==1
replace recent_protest = 0 if time_since_protest>186 & sample==1 
tab recent_protest
replace recent_protest=. if time_since_protest==.
gen use_prot_history = .
replace use_prot_history = 3 if recent_protest == 5 & sample == 1
replace use_prot_history = 2 if recent_protest == 4 & sample == 1
replace use_prot_history = 1 if recent_protest == 3 & sample == 1
replace use_prot_history = 1 if recent_protest == 2 & sample == 1
replace use_prot_history = 0 if recent_protest == 1 & sample == 1
replace use_prot_history = 0 if recent_protest == 0 & sample == 1
replace use_prot_history = . if recent_protest==.
gen Robustness_Dis_Cost = use_prot_history + disruptionlocation + length if sample==1
sum Robustness_Dis_Cost
sum Robustness_Dis_Cost if sample==0
sum Robustness_Dis_Cost if sample==.
tab Robustness_Dis_Cost
sort ccode id
gen corruption =0 & sample == 1
replace corruption =1 if protesterdemand1==5 & sample == 1
replace corruption =1 if protesterdemand3==5 & sample == 1
replace corruption =1 if protesterdemand2==5 & sample == 1
gen ln_PartNumbers_low = ln(PartNumbers_low)
sum state_response disruption_cost_index concession_cost_index last2violent number_of_demands CNTS_regime CNTS_headofstate gwf_party gwf_military gwf_monarchy gwf_personal gwf_democracy ln_gdppercap Youth_Bulge PHYSINT StateDept lrexclpop previous_SR previous_CCI previous_DCI Robustness_Dis_Cost previousviolence previousviolence2 corruption protesterviolence ln_PartNumbers_low
tab state_response


// Table 23 //
////// SPLIT SAMPLE MULTINOMIAL LOGIT REGRESSION RESULTS /////
split protesteridentity, p(, &)
sort ccode id
gen SameGroup = .
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity1[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity2[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity3[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity4[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity5[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity6[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity7[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity8[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity9[_n+1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity1[_n-1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity2[_n-1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity3[_n-1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity4[_n-1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity5[_n-1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity6[_n-1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity7[_n-1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity8[_n-1]
by ccode: replace SameGroup = 1 if protesteridentity1[_n]==protesteridentity9[_n-1]
replace SameGroup = 0 if SameGroup == .

// Model A56 //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if SameGroup==1, cluster(ccode)
//  Model A57  //
mlogit state_response disruption_cost_index concession_cost_index previous_SR last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if SameGroup==1, cluster(ccode)
//  Model A58  //
mlogit state_response disruption_cost_index concession_cost_index previous_CCI previous_DCI last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if SameGroup==1, cluster(ccode)

//  Model A59  //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if SameGroup==0, cluster(ccode)
//  Model A60  //
mlogit state_response disruption_cost_index concession_cost_index previous_SR last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if SameGroup==0, cluster(ccode)
//  Model A61  //
mlogit state_response disruption_cost_index concession_cost_index previous_CCI previous_DCI last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge if SameGroup==0, cluster(ccode)


// Table A24 //
//////  ROLE OF CORRUPTION DEMAND & PROTESTER VIOLENCE ON COST PARAMETERS & STATE RESPONSE [MULTINOMIAL LOGIT REGRESSION]  //////

// Model A62 //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge protesterviolence, cluster(ccode)
// Model A63 //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge corruption, cluster(ccode)
// Model A64 //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge corruption protesterviolence, cluster(ccode)


// Table A25 //
/////  Robustness Check – Alternative Political Regime & Human Rights Specifications [Multinomial Logit]  /////

//  Model A65  //
mlogit state_response disruption_cost_index concession_cost_index CNTS_regime CNTS_headofstate last2violent number_of_demands ln_gdppercap Youth_Bulge, cluster(ccode)
//  Model A66  //
mlogit state_response disruption_cost_index concession_cost_index CNTS_regime CNTS_headofstate last2violent number_of_demands ln_gdppercap Youth_Bulge StateDept, cluster(ccode)
//  Model A67  //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge StateDept, cluster(ccode)
//  Model A68  //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands CNTS_regime CNTS_headofstate ln_gdppercap Youth_Bulge PHYSINT, cluster(ccode)
//  Model A69  //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge PHYSINT, cluster(ccode)


// Table A26 //
//////  Robustness Check – Government Type [Multinomial Logit]  /////

// Model A70 //
// GWF_MILITARY IS REFERENCE CATEGORY //
mlogit state_response disruption_cost_index concession_cost_index gwf_party gwf_monarchy gwf_personal gwf_democracy last2violent number_of_demands ln_gdppercap Youth_Bulge, cluster(ccode)


//  Table A27  //
/////  Robustness Check – Ethnopolitical Relations Specifications [Multinomial Logit]  /////

//  Model A71  //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge lrexclpop , cluster(ccode)


//  Table A28  //
/////  Robustness Check – Alternative Disruption Costs Index Specification [Multinomial Logit]  /////

//  Model A72  //
mlogit state_response Robustness_Dis_Cost concession_cost_index, cluster(ccode)

//  Model A73 //
mlogit state_response Robustness_Dis_Cost concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge ln_PartNumbers_low, cluster(ccode)


//  Table A29  //
///// Robustness Check – Split Protest Violence(t-1)  [Multinomial Logit]  /////
sort ccode protest id
by ccode: gen pastviolence = .
by ccode: replace pastviolence = protesterviolence[_n-1] if protest==1
by ccode: gen pastviolence2 = .
by ccode: replace pastviolence2 = protesterviolence[_n-2] if protest==1

// Model A74  //
mlogit state_response disruption_cost_index concession_cost_index, cluster(ccode) 

// Model A75  //
mlogit state_response disruption_cost_index concession_cost_index polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode) 

// Model A76  // 
mlogit state_response disruption_cost_index concession_cost_index pastviolence pastviolence2 number_of_demands, cluster(ccode)

// Model A77  // 
mlogit state_response disruption_cost_index concession_cost_index pastviolence pastviolence2 number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge, cluster(ccode)


//  Table A30  //
//////  Determinants of State Response(t) [Multinomial Logit]  /////

//  Model A78 //
mlogit state_response disruption_cost_index concession_cost_index previous_SR, cluster(ccode)
//  Model A79 //
mlogit state_response disruption_cost_index concession_cost_index previous_DCI previous_CCI, cluster(ccode)
//  Model A80 //
mlogit state_response disruption_cost_index concession_cost_index previous_SR  previousviolence number_of_demands region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)
//  Model A81 //
mlogit state_response disruption_cost_index concession_cost_index previous_DCI previous_CCI previousviolence number_of_demands  region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)
//  Model A82 //
mlogit state_response disruption_cost_index concession_cost_index test_coercion_lag test_accom_lag test_police_lag test_disregard_lag previousviolence number_of_demands  region polity2 polity2_squared Youth_Bulge ln_gdppercap, cluster(ccode)


//  Table A31  //
/////  Robustness Check - Fixed Effects by Country [Multinomial Logit]  /////

// Model A83 //
mlogit state_response disruption_cost_index concession_cost_index last2violent number_of_demands polity2 polity2_squared ln_gdppercap Youth_Bulge i.ccode if testsample4==1, vce(robust)
outreg2 using "Manuscript_Table1", replace excel alpha(0.001, 0.01, 0.05) 
